<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../../commons/taglibs.jsp"%>
<%@ include file="../../commons/list.jsp"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta charset="utf-8">
  <title>用户管理</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <style type="text/css">
  	input{
  		width: 200px;
  		display: inline;
  	}
  </style>
</head>

<body>
 <div>
	<div style="padding: 50px;padding-top: 50px">
		<form class="layui-form layui-form-pane"  action="">
		<input type="hidden" id='entityId' name='entityId' value="${sysUserRobot.id }">
		  
		   <div class="layui-form-item" style="width: 85%;padding-left: 40px">
		     <label class="layui-form-label">用户名</label>
		    <div class="layui-input-block">
		    	<select name="userid" lay-verify="required">
				  <option value="">请选择一个用户</option>
				  <c:forEach items="${sysUserList }" var="sysUsers">
				  
				  		<c:if test="${sysUserRobot.userid eq sysUsers.userid }">  
					  		<option value="${sysUsers.userid }" selected >${sysUsers.username }</option>
				  		 </c:if>  
				  
				  		<c:if test="${sysUserRobot.userid ne sysUsers.userid }">  
					  		<option value="${sysUsers.userid }" >${sysUsers.username }</option>
				  		 </c:if>  
				  		
				  </c:forEach>
				</select>
		    </div>
		  </div>
		  
		  <div class="layui-form-item" style="width: 85%;padding-left: 40px">
		    <label class="layui-form-label">机器人编码</label>
		     <div class="layui-input-block">
		      <input type="text" name="robotcode" value="${sysUserRobot.robotcode}" required  lay-verify="required" placeholder="请输入机器人编码" autocomplete="off" class="layui-input">
		    </div>
		  </div>
		  
		  <div class="layui-form-item" style="width: 85%;padding-left: 40px;padding-top: 30px">
		    <div class="layui-input-block">
		      <button class="layui-btn" id='tjsub' lay-submit lay-filter="formDemo">立即提交</button>
		      <a class="layui-btn" onclick="closeWindow()"><i class="layui-icon">&#xe65c;</i>返回</a>
		    </div>
		  </div>
		</form>
	</div>
 </div> 

<script>
layui.use('form', function(){
	  var form = layui.form;
	   //监听提交
	  form.on('submit(formDemo)', function(data){
		  //提交成功后禁用按钮
		  $("#tjsub").css("pointer-events","none"); 
		  $.post('<%=basePath%>controller/sysUserRobot/save',data.field,function(data){
			  if(data == '1'){
				  $("#tjsub").css("pointer-events","auto");
				  layer.msg('提交失败', {time:1000});
			  }
			  if(data == '0'){
				  layer.msg('提交成功', {time:1000});
				  setTimeout("layer.closeAll()",1000);
				  //调用刷新页面
				  setTimeout("parent.location.reload()",2000);
				  
			  }
			  if(data == '2'){
				  $("#tjsub").css("pointer-events","auto");
				  layer.msg('已存在该登录名，请换一个', {time:2000});
			  }
		  })
	    return false;
	  });
	   
	  form.render();
		
 });
 
//返回按钮事件
function closeWindow(){
        var index = parent.layer.getFrameIndex(window.name);
		parent.layer.close(index);
} 
      
</script>
</body>
</html>
